﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Sucdri.Domain.Model;
using Sucdri.Domain.Repository.DataMapper;
using Sucdri.Infrastructure.Core.Extensions;

namespace Sucdri.Domain.Repository
{
   public class ProjectMainRepository
   {
      private readonly ProjectMainDataMapper _dataMapper;

      public ProjectMainRepository()
      {
         _dataMapper=new ProjectMainDataMapper();
      }

      public void Create(ProjectMain model)
      {
         if (UnitOfWork.Current != null)
            UnitOfWork.Current.RegisterNew(model);
         else
            _dataMapper.Create(model);
         
      }

      public void Update(ProjectMain model)
      {
         if (UnitOfWork.Current != null)
            UnitOfWork.Current.RegisterDirty(model);
         else
            _dataMapper.Update(model);

      }

      public void Delete(ProjectMain model)
      {
         if (UnitOfWork.Current != null)
            UnitOfWork.Current.RegisterRemoved(model);
         else
            _dataMapper.Delete(model);

      }

   }
}
